package com.ithe.cart.config;

import com.ithe.cart.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * Created by zxd on 2022/5/7
 */
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {


    @Bean
    public LoginInterceptor loginInterceptor(){
        return new LoginInterceptor();
    }

    //配置拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //定义排除swagger访问的路径配置
        String[] swaggerExcludes=new String[]{"/swagger-ui/index.html","/swagger-resources/**","/webjars/**"};
        registry.addInterceptor(loginInterceptor())
                .addPathPatterns("/app-api/v1/carts/**");
               // .excludePathPatterns(swaggerExcludes);
    }
}
